#include <stdio.h>
#include <string.h>
/*my_strToHex*/
unsigned char my_atoi(char *b)
{
	char c[2];
	unsigned char val = 0;
	for(int i = 0;i < 2; i++){
		if(*(b + i) >= 'A' && *(b + i) <= 'F'){
			c[i] = *(b + i) + 32;
			c[i] -= 87;
		}else if(*(b + i) >= '0' && *(b + i) <= '9'){
			c[i] = *(b + i);
			c[i] -= '0';
		}else if(*(b + i) >= 'a' && *(b + i) <= 'f'){
			c[i] = *(b + i);
			c[i] -= 87;
		}else
			return 0;
		if(i == 0)
			val = c[i] << 4;
		if(i == 1)
			val |= c[i]; 
	}
	return val;
}

int my_strToHex(unsigned char *des,char *src)
{
	int len = strlen(src);
	if(len % 2 != 0) return 0;
	
	for(int i=0;i< len / 2;i++){

		des[i] = my_atoi(src + i*2);
//		printf("pd[%d]:%x\n",i,pd[i]);
	}

	return len / 2;
}

int main()
{
	unsigned char des[10];
	char *src = "236a";
	int len = my_strToHex(des,src);
	for(int i = 0;i< len;i++){
		//TODO
		printf("0x%02X ",des[i]);
	}

	return 0;
}
